﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>添加日志</title>
    <link href="css/blog_add.css" rel="stylesheet" type="text/css" media="all">
    <script src="/js/axios.min.js" language="JavaScript"></script>
    <script src="/js/vue.min.js" language="JavaScript"></script>
</head>

<body>
<div id="addDiv">
    <div id="head">
    </div>


    <div id="body">
        <h1>添加日志</h1>
        <p>日志标题 *
            <span><input name="" type="button" value="保存"/>
<input name="" type="button" value="发布"/>
<input name="" type="button" value="返回"/></span></p>
        <p><input name="title" v-model="title" type="text" class="t_input"/></p>
        <p>发布时间 *</p>
        <p><input name="modifytime" v-model="modifytime" type="Date"/></p>
        <p>日志分类 *</p>
        <p><!--<input name="" v-model="categoryid" type="checkbox" value="" />-->
            <select name="categoryid" v-model="categoryid">
                <option value="">选择类型</option>
                <option value="1">java</option>
                <option value="2">vue</option>
                <option value="3">git</option>
            </select>
            Java
        </p>
        <p>日志内容 *</p>
        <p><textarea name="content" v-model="content" cols="80" rows="12"></textarea></p>
        <p>日志摘要</p>
        <p><textarea name="summary" cols="80" rows="8"></textarea></p>
        <p><!--<input name="InsertEntry" @click="InsertEntry()" type="button" value="保 存"/>-->
            <button @click="InsertEntry()" value="提交">提交</button>
            <input name="" type="button" value="发 布"/></p>
    </div>

    <div id="foot">
        <hr/>
        <center>Copyright &copy; 2013-2020</center>
    </div>
</div><!--addDiv结尾-->
</body>
<script>
    var vm = new Vue({
        el: "#addDiv",
        data: {
            title: '',
            modifytime: '',
            categoryid: '',
            content: '',
            summary: ''
        },
        methods: {
            InsertEntry: function () {
                var path = "/add";
                var param = {
                    "title": vm.title,
                    "modifytime": vm.modifytime,
                    "categoryid": vm.categoryid,
                    "content": vm.content,
                    "summary": vm.summary
                };
                axios.post(path, param).then(function (obj) {
                    if (obj.status == 200) {
                        var pageResult = obj.data;
                        if (pageResult.code == 100) {
                            alert("添加失败");
                            return;
                        }
                        alert("添加成功！！！" + vm.title + vm.modifytime + vm.categoryid + vm.content + vm.summary);
                        location.href="blog_manage.html";
                    }
                }).catch(function () {
                    alert("添加发生了错误");
                });
            }
        }
    });
</script>
</html>
